import java.util.Arrays;

public class Client {
    public static void main(String[] args) {
        DataOperation dataOperation = new OperationAdapter(new QuickSort(), new BinarySearch());

        int[] array = {12, 45, 1, 23, 78, 45, 67, 34};
        System.out.println("原始的数组: " + Arrays.toString(array));

        // 测试排序
        dataOperation.sort(array);
        System.out.println("实现快速排序：");
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i] + " ");
        }
        System.out.println();

        System.out.println("实现二分查找算法：");
        // 测试查找
        int key = 45;
        int index = dataOperation.search(array, key);
        if (index != -1) {
            System.out.println( key + " found at index: " + index);
        } else {
            System.out.println( key + " not found in the array.");
        }

        // 测试查找不存在的元素
        key = 100;
        index = dataOperation.search(array, key);
        if (index != -1) {
            System.out.println( key + " found at index: " + index);
        } else {
            System.out.println( key + " not found in the array.");
        }
    }
}